package api

import (
	"github.com/labstack/echo/v4"
	"longmen/server/pkg/common/api_models"
	"longmen/server/pkg/common/helper/const"
	"longmen/server/pkg/common/helper/util"
)

//主播排行榜
func (base *Controller) GetAnchorRankList(c echo.Context) error {
	r := &api_models.GetAnchorRankListReq{}
	if err := util.Json2Struct(c.Get("body").(string), r); err != nil {
		return util.BadParam(c, err)
	}
	if err := _const.Validate.Struct(r); err != nil {
		return util.BadParam(c, err)
	}

	//测试用数据
	resp, err := base.Service.CreateTestAnchorIncomeModels(r.Uid)
	if err != nil {
		return util.BuildFail(c, 1, "", err)
	}
	return util.BuildSuccess(c, resp, "")

	//resp, err = base.Service.GetAnchorRankList(r)
	//if err != nil {
	//    return common.BuildFail(c, 1, "", err)
	//}
	//return common.BuildSuccess(c, resp, "")
}

//用户排行榜
func (base *Controller) GetUserRankList(c echo.Context) error {
	r := &api_models.GetUserRankListReq{}
	if err := util.Json2Struct(c.Get("body").(string), r); err != nil {
		return util.BadParam(c, err)
	}
	if err := _const.Validate.Struct(r); err != nil {
		return util.BadParam(c, err)
	}

	//测试用数据
	resp, err := base.Service.CreateTestUserConsumeModels(r.Uid)
	if err != nil {
		return util.BuildFail(c, 1, "", err)
	}
	return util.BuildSuccess(c, resp, "")

	//resp, err = base.Service.GetUserRankList(r)
	//if err != nil {
	//    return common.BuildFail(c, 1, "", err)
	//}
	//return common.BuildSuccess(c, resp, "")
}
